/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lianxishilili.demo;

/**
 *
 * @author Administrator
 */
public class BirthdayNumber {
     public static void main(String[] args) {
        String birthnumber="19491001";
        boolean flag=true;
        if(birthnumber.length()!=8){
        flag=false;
         }
     
        if(!(birthnumber.startsWith("1")||birthnumber.startsWith("2"))){
        flag=false;
        }
       String numstr="01234567";
        for(int i=0;i<birthnumber.length();i++){
        char c=birthnumber.charAt(i);
        int temp=numstr.indexOf(c);
        if(temp<0){
        flag=false;
        break;
        }
        }
        if(flag){
            System.out.println("是合法的生日");
        }
        else{
            System.out.println("不是合法的生日");
         }
    }
}
